*Dataset with singles*

*Load data*
clear

use "Data\dataset_with_singles.dta" 

*Age restrictions*
gen age=alder
destring age, replace

sort couple_id aar
by couple_id aar: gen age_m = age if koen=="1" & relationship==1
by couple_id aar: gen age_f = age if koen=="2" & relationship==1
by couple_id aar: egen maxage = max(age_m)
by couple_id aar: replace age_m = maxage
drop maxage
by couple_id aar: egen maxage = max(age_f)
by couple_id aar: replace age_f = maxage
drop maxage

* Singles age 40-49, couples with at least one spouse age 40-49
gen insample = 0
replace insample = 1 if relationship == 0 & age >= 40 & age <= 49
replace insample = 1 if relationship == 1 & ((age_m >= 40 & age_m <= 49) | (age_f >= 40 & age_f <= 49))
keep if insample == 1
drop insample age age_f age_m




****


*Save*
save "Results\tab_B3\Scenario_14\dataset_with_singles_age40to49.dta", replace

